package com.hrzyit.whistle.user.service.impl

import com.hrzyit.base.ext.convert
import com.hrzyit.base.ext.convertBoolean
import com.hrzyit.whistle.user.data.bean.UserInfo
import com.hrzyit.whistle.user.data.repository.UserRepository
import com.hrzyit.whistle.user.service.IUserService
//import rx.Observable
import io.reactivex.Observable
import javax.inject.Inject

/**
 * 用户模块业务接口实现类
 * @author YangWei
 * @date 2019/3/23
 */
class UserServiceImpl @Inject constructor() : IUserService {

    // Dagger2 注入
    @Inject
    lateinit var userRepository: UserRepository

    override fun login(
        account: String, mobile: String, pwd: String, pushId: String
    ): Observable<UserInfo> {

        return userRepository.login(
            account, mobile, pwd, pushId
        ).convert()
    }

    override fun forgetPwd(mobile: String, verifyCode: String): Observable<Boolean> {
        return userRepository.forgetPwd(
            mobile, verifyCode
        ).convertBoolean()
    }

    override fun resetPwd(mobile: String, newPwd: String): Observable<UserInfo> {
        return userRepository.resetPwd(mobile,newPwd).convert()
    }
}